﻿using TencentCloud.Iai.V20200303;
using TencentCloud.Iai.V20200303.Models;

namespace FaceRecognizer
{
    public class Group
    {
        public string Name { get; set; }

        public string Id { get; set; }

        /// <summary>
        /// 给他的名字和id赋值
        /// </summary>
        /// <param name="name"></param>
        /// <param name="id"></param>
        public Group(string name, string id)
        {
            Name = name;
            Id = id;
        }

        /// <summary>
        /// 创建人员库
        /// </summary>
        /// <param name="client"></param>
        /// <param name="name"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public CreateGroupResponse Create(IaiClient client, string name, string id)
        {
            CreateGroupRequest createGroupRequest = new CreateGroupRequest();
            createGroupRequest.GroupName = name;
            createGroupRequest.GroupId = id;
            //返回的resp是一个CompareFaceResponse的实例，与请求对象对应
            return client.CreateGroupSync(createGroupRequest);
        }
        /// <summary>
        /// 删除人员库
        /// </summary>
        /// <param name="personid"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        public DeleteGroupResponse delete(string personid, IaiClient client)
        {
            DeleteGroupRequest deleteGroupReques = new DeleteGroupRequest();
            deleteGroupReques.GroupId = personid;
            return client.DeleteGroupSync(deleteGroupReques);
        }
        /// <summary>
        /// 更改人员库
        /// </summary>
        /// <param name="client"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public ModifyGroupResponse Modify(IaiClient client, string id)
        {
            ModifyGroupRequest ｍodifyGroupRequest = new ModifyGroupRequest();
            ｍodifyGroupRequest.GroupId = id;
            // 返回的resp是一个ModifyGroupResponse的实例，与请求对象对应
            return client.ModifyGroupSync(ｍodifyGroupRequest);
        }
        /// <summary>
        /// 获取人员库信息
        /// </summary>
        /// <param name="client"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public GetGroupInfoResponse GetInfo(IaiClient client, string groupId)
        {
            GetGroupInfoRequest getGroupInfoRequest = new GetGroupInfoRequest();
            getGroupInfoRequest.GroupId = groupId;
            return client.GetGroupInfoSync(getGroupInfoRequest);
        }
        /// <summary>
        /// 查看人员库中对应的人员信息
        /// </summary>
        /// <param name="client"></param>
        /// <param name="personId"></param>
        /// <returns></returns>
        public GetPersonBaseInfoResponse GetBaseInfo(IaiClient client, string personId)
        {
            GetPersonBaseInfoRequest getPersonBaseInfoRequest = new GetPersonBaseInfoRequest();

            getPersonBaseInfoRequest.PersonId = personId;
            // 返回的resp是一个GetPersonBaseInfoResponse的实例，与请求对象对应
            return client.GetPersonBaseInfoSync(getPersonBaseInfoRequest);
        }

        public SearchPersonsResponse SearchPersons(string image, IaiClient client, string[] strings)
        {
            SearchPersonsRequest searchPersonsRequest = new SearchPersonsRequest();

            searchPersonsRequest.GroupIds = strings;

            searchPersonsRequest.Image = image;

            // 返回的resp是一个SearchPersonsResponse的实例，与请求对象对应
            return client.SearchPersonsSync(searchPersonsRequest);
        }
    }
}
